import java.util.Arrays;

public class test {
    /**
     * 微信红包问题
     * @param array
     * @param n
     * @return
     */
    public static int getValue(int[] array, int n){
        //进行数组排序
        Arrays.sort(array);
        int mid = array[n/2];
        int count = 0;
        for ( int x:array) {
            if(mid == x){
                count++;
            }
        }
        if(count > n/2){
            return mid;
        }else{
            return 0;
        }
    }
    public static void main(String[] args) {
        int[] array = {1,2,3,2,3};
        int n = 5;
        System.out.println(getValue(array,n));
    }
}
